//
//  SLWKNavigationDelegate.m
//  ShopLeader
//
//  Created by 帅科 on 2020/5/27.
//  Copyright © 2020 ShopLeader. All rights reserved.
//

#import "QSNavigationDelegate.h"

@interface QSNavigationDelegate ()
@property (nonatomic ,weak) SLBaseWebViewController*webVC;
@end

@implementation QSNavigationDelegate

- (instancetype)initWithWebVC:(SLBaseWebViewController *)webVC{
    if (self = [super init]) {
        self.webVC = webVC;
    }
    return self;
}


- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
    
    WKNavigationActionPolicy navigationActionPolicy = [self.webVC webView:webView decidePolicyForNavigationAction:navigationAction];
    decisionHandler(navigationActionPolicy);
}

- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler {
    WKNavigationResponsePolicy navigationResponsePolicy = [self.webVC webView:webView decidePolicyForNavigationResponse:navigationResponse];
    decisionHandler(navigationResponsePolicy);
}


- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation {
    [self.webVC webView:webView didStartProvisionalNavigation:navigation];
}


- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(null_unspecified WKNavigation *)navigation {
    [self.webVC webView:webView didReceiveServerRedirectForProvisionalNavigation:navigation];
}


- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error {
    [self.webVC webView:webView didFailProvisionalNavigation:navigation withError:error];
}

- (void)webView:(WKWebView *)webView didCommitNavigation:(null_unspecified WKNavigation *)navigation {
    [self.webVC webView:webView didCommitNavigation:navigation];
}

- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation {
    [self.webVC webView:webView didFinishNavigation:navigation];
}

- (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error {
    [self.webVC webView:webView didFailNavigation:navigation withError:error];
}

- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView {
    [self.webVC webViewWebContentProcessDidTerminate:webView];
}


@end

